<script setup lang='ts'>
  import { onMounted, reactive, ref } from 'vue';
  import { lassoCattleApi } from "@/api/controller";
  import configForm from './configForm.vue';
  const configFormRef = ref()
  const action = reactive({
    list:[] as Array<any>
  })
  const handleForm = (row:any = {})=>{
    configFormRef.value.openDialog(row)
  }
  const getConfigInfo = async()=>{
    const res = await lassoCattleApi.getConfig()
    const {
      lassoCattle_max='',lassoCattle_not_yet_released='',
      lassoCattle_profit_rate='', lassoCattle_reward_max='',
      lassoCattle_reward_min='',lassoCattle_screen_min='',
      lassoCattle_stake={1:'',2:'',3:''}, lassoCattle_stream_max='',
      lassoCattle_warn_num=''
    } = res?.data || {}
    action.list = [
      {id:1,text:'飘屏通知下限值',integral:lassoCattle_screen_min,key:'lassoCattle_screen_min'},
      {id:2,text:'利润率(百分位)',integral:lassoCattle_profit_rate,key:'lassoCattle_profit_rate'},
      {id:3,text:'下限值',integral:lassoCattle_reward_min,key:'lassoCattle_reward_min'},
      {id:4,text:'上限值',integral:lassoCattle_reward_max,key:'lassoCattle_reward_max'},
      {id:5,text:'每轮礼物池参与上限',integral:lassoCattle_max,key:'lassoCattle_max'},
      {id:6,text:'开奖连续未出次数',integral:lassoCattle_not_yet_released,key:'lassoCattle_not_yet_released'},
      {id:7,text:'单个玩家输赢上限值',integral:lassoCattle_stream_max,key:'lassoCattle_stream_max'},
      {id:8,text:'单个玩家每个小时输赢超过多少个券报警',integral:lassoCattle_warn_num,key:'lassoCattle_warn_num'},
      {id:9,text:'参与类型',integral:lassoCattle_stake,key:'lassoCattle_stake'},
    ]
  }
  onMounted(()=>{
    getConfigInfo()
  })
</script>

<template>
  <div class="xm-content">
    <el-table
      class="xm-main xm-TableCenter"
      :data="action.list"
      border>
      <el-table-column min-width="120" prop="text" label="配置名称" />
      <el-table-column min-width="120" prop="integral" label="配置内容">
        <template #default="scope">
          <template v-if="scope.row.id == 9">
            <div v-for="(item,key) of scope.row.integral">
              参与类型{{ key }}：{{ item }}券
            </div>
          </template>
          <template v-else-if="scope.row.id == 2">{{ scope.row.integral }}%</template>
          <template v-else>{{ scope.row.integral }}</template>
        </template>
      </el-table-column>
      <el-table-column width="180" fixed=right label="操作">
        <template #default="scope">
          <el-button type="primary" @click="handleForm(scope.row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <configForm ref="configFormRef" @update-list="getConfigInfo" />
  </div>
</template>

<style lang='scss' scoped>

</style>
